package com.itita.ww2.handler.requesthandler.worldmap;

import java.sql.SQLException;

import com.itita.ww2.core.MessageHandler;
import com.itita.ww2.core.WW2Exception;
import com.itita.ww2.game.user.UserService;
import com.itita.ww2.game.worldmap.WorldMapService;
import com.itita.ww2.model.user.UserProfile;
import com.itita.ww2.utils.handler.IRequestOper;
import com.smartfoxserver.v2.entities.User;
import com.smartfoxserver.v2.entities.data.ISFSObject;

/**
 * 宣战(指定联盟成员(role)对指定level的城池进行宣战)
 * @author NorthLan
 *
 */
public class DeclarWar implements IRequestOper {

	@Override
	public boolean execute(String requestCMD, User user, ISFSObject params) throws WW2Exception, SQLException {
		UserProfile userProfile = UserService.getInstance().getUserProfile(user);
		int blockId = params.getInt("blockId");
		int cityId = params.getInt("cityId");

		WorldMapService.declarWar(userProfile, blockId, cityId);

		// 回传
		MessageHandler.getInstance().sendMsg(requestCMD, null, user, null, true);
		return true;
	}

}
